#include "GL/glut.h"
#include "demo.h"
#include "time.h"
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iostream>
using namespace std;

const double thePAI=3.1416;

extern double radiu, angle;
extern double ax, ay, aa;
extern double rx,ry,rcolor;

double func(double x, double y)
{
	double val;
	val=sin(6*x)+cos(9*y);
	//val = y - 5.1*x*x/4.0/thePAI + 5.0*x/PAI - 6.0;
	//val = val * val;
	//val += 10;
	//val = val + 100.0*(1-1.0/8.0/thePAI)*cos(x);
	return val/3.0;
}

double func1(double x, double y)
{
	double val;

	x *= 2.8;
	y *= 2.8;
	val=x*x*x*x*x*x/3.0;
	val += x*x*x*x*2.1 + 4*x*x;		
	val += x*y + 4*y + 4*y*y;

	val= val>0 ? val/3.0 : val;

	return val/50.0;
}

void demo1()
{
	glColor3f(1.0, 0.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT);
	glutWireSphere(0.8,18,18);
	glFlush();
	
}

void demo2()
{
	glClear(GL_COLOR_BUFFER_BIT);

	glPushMatrix();
	glClear(GL_COLOR_BUFFER_BIT);	
	glPushMatrix();
	glRotatef(45.0, 0.0, 1.0, 0.0);
    
	glColor3f(1.0, 0.0, 0.0);
	glBegin(GL_LINES);
	glVertex3f(-1.0,0.0,0.0);
	glVertex3f(1.0,0.0,0.0);   
	glEnd();
	glFlush();
	
	glColor3f(0.0, 1.0, 0.0);
	glBegin(GL_LINES);
	glVertex3f(0.0,1.0,0.0);
	glVertex3f(0.0,-1.0,0.0);
	glEnd();
	glFlush();
        
	glColor3f(0.0, 0.0, 1.0);
	glBegin(GL_LINES);
	glVertex3f(0.0, 0.0, 1.0);
	glVertex3f(0.0, 0.0, -1.0);
	glEnd();
	glFlush();	
	glPolygonMode(GL_FRONT,GL_FILL);
	glPolygonMode(GL_BACK,GL_LINE);
	
	glBegin(GL_POLYGON);
	glVertex3f(0.0,0.0,0.1);
	glVertex3f(0.4,0.5,0.5);
	glVertex3f(0.8,0.5,0.3);
	glVertex3f(1.0,0.0,-0.2);	
	glEnd();		
	glFlush();	
	
	usleep(1);

	glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
	glBegin(GL_POLYGON);
	glVertex3f(0.0,0.0,0.1);
	glVertex3f(0.4,0.5,0.5);
	glVertex3f(0.8,0.5,0.3);
	glVertex3f(1.0,0.0,-0.2);	
	glEnd();		
	glFlush();	

	glPopMatrix();        
}

void demo3()
{
	glPushMatrix();
	glClear(GL_COLOR_BUFFER_BIT);
	glRotatef(-45.0,0.0,1.0,0.0);
	glColor3f(0.0, 1.0, 1.0);
	glBegin(GL_LINES);
	glVertex3f(0.0,1.0,0.0);
	glVertex3f(0.0,-1.0,0.0);
	glEnd();
	
	glBegin(GL_LINES);
	glVertex3f(-1.0,0.0,0.0);
	glVertex3f(1.0,0.0,0.0);   
	glEnd();
	
	glBegin(GL_LINES);
	glVertex3f(0.0, 0.0, 1.0);
	glVertex3f(0.0, 0.0, -1.0);
	glEnd();
	glFlush();	
	for(double a=0.0; a<2.0*3.1416; a+=0.02)
	{
		glColor3f(a/(2.0*3.1416), 1.0-a/(2.0*3.1416), 0.8);
		glBegin(GL_POINTS);
       	glVertex2f(a/3.1416 - 1.0, sin(2.0*a));
		glEnd();		
		glFlush();
		usleep(2);
	}
	glPopMatrix();

}

void demo4()
{
	for(double k=0.0; k<270.0;k += 1.0)
	{
	glClear(GL_COLOR_BUFFER_BIT);	
	
	glPushMatrix();
	glRotatef(k,0.0,0.0,1.0);
	
	glColor3f(0.2, 0.2, 1.0);
	glBegin(GL_LINES);
	glVertex3f(0.0,1.0,0.0);
	glVertex3f(0.0,-1.0,0.0);
	glEnd();
	
	glBegin(GL_LINES);
	glVertex3f(-1.0,0.0,0.0);
	glVertex3f(1.0,0.0,0.0);   
	glEnd();
	
	glBegin(GL_LINES);
	glVertex3f(0.0, 0.0, 1.0);
	glVertex3f(0.0, 0.0, -1.0);
	glEnd();
	
	glFlush();

	glColor3f(0.2, 0.8, 1.0);
	
	for(double a=0.0; a<2.0*3.1416; a+=0.04)
	{       		
		glBegin(GL_POINTS);
       	glVertex3f(sin(2.0*a)/2.0, 0.0, a/3.1416 - 1.0);
		glEnd();	
		glFlush();			
	}
	glPopMatrix();
	usleep(3);
	}
}

void demo5()
{
	for(double kk=0.0; kk<180.0; kk += 1.0)
	{
	glClear(GL_COLOR_BUFFER_BIT);	
	
	glPushMatrix();
	double dtor=kk * 3.1416 / 180.0;
	//glRotatef(k,0.0,0.0,1.0);
	gluLookAt(0.3,cos(dtor)/3,sin(dtor)/3,
		     0.0, 0.0, 0.0,
			  -sin(dtor)/3,0.0,0.0);
	
	glColor3f(0.0, 1.0, 0.0);
	glBegin(GL_LINES);
	glVertex3f(0.0,1.0,0.0);
	glVertex3f(0.0,-1.0,0.0);
	glEnd();
	glFlush();
	
	glColor3f(1.0, 0.0, 0.0);
	glBegin(GL_LINES);
	glVertex3f(-1.0,0.0,0.0);
	glVertex3f(1.0,0.0,0.0);   
	glEnd();
	glFlush();
	
	glColor3f(0.0, 0.0, 1.0);
	glBegin(GL_LINES);
	glVertex3f(0.0, 0.0, 1.0);
	glVertex3f(0.0, 0.0, -1.0);
	glEnd();
	glFlush();
	glColor3f(1.0, 0.0, 1.0);
	double a;
	for(a=0.0; a<3.1416; a+=0.02)
	{
		
		glBegin(GL_POINTS);
       	glVertex3f(sin(2.0*a)/2.0, 0.0, a/3.1416 - 1.0);
		glEnd();			
	}	
	glFlush();
	
	glColor3f(0.8, 1.0, 0.0);
	for(a=3.1416; a<2.0*3.1416; a+=0.02)
	{
		
		glBegin(GL_POINTS);
       	glVertex3f(sin(2.0*a)/2.0, 0.0, a/3.1416 - 1.0);
		glEnd();		
		glFlush();
		
	}
	glPopMatrix();
	usleep(5);
	}
}

void demo6()
{
	glClear(GL_COLOR_BUFFER_BIT);
	for(aa=0.0; aa<380.0; aa+=2.0)
	{
		glPushMatrix();
		glClear(GL_COLOR_BUFFER_BIT);	
		glPushMatrix();
		glRotatef(aa,0.0,1.0,0.0);
        
		glColor3f(1.0, 0.0, 0.0);
		glBegin(GL_LINES);
		glVertex3f(-1.0,0.0,0.0);
		glVertex3f(1.0,0.0,0.0);   
		glEnd();
		glFlush();

		glColor3f(0.0, 1.0, 0.0);
		glBegin(GL_LINES);
		glVertex3f(0.0,1.0,0.0);
		glVertex3f(0.0,-1.0,0.0);
		glEnd();
		glFlush();
        
		glColor3f(0.0, 0.0, 1.0);
		glBegin(GL_LINES);
		glVertex3f(0.0, 0.0, 1.0);
		glVertex3f(0.0, 0.0, -1.0);
		glEnd();
		glFlush();	
		
		glColor3f(0.6, 0.0, 0.6);
		glutWireTeapot(0.7);
		//glutWireCube(0.7);
		//glutSolidTeapot(0.7);
		glFlush();	
		usleep(3);
		glPopMatrix();        
	}	
}

void demo7()
{
	for(aa=0.0; aa<380.0; aa+=1.0)
	{	
	glClear(GL_COLOR_BUFFER_BIT);	
	glPushMatrix();
	glRotatef(aa,0.0,1.0,0.0);
	
	glColor3f(1.0, 0.0, 0.0);
	glBegin(GL_LINES);
	glVertex3f(-1.0,0.0,0.0);
	glVertex3f(1.0,0.0,0.0);   
	glEnd();
	glFlush();


	glColor3f(0.0, 1.0, 0.0);
	glBegin(GL_LINES);
	glVertex3f(0.0,1.0,0.0);
	glVertex3f(0.0,-1.0,0.0);
	glEnd();
	glFlush();
	
	glColor3f(0.0, 0.0, 1.0);
	glBegin(GL_LINES);
	glVertex3f(0.0, 0.0, 1.0);
	glVertex3f(0.0, 0.0, -1.0);
	glEnd();
	glFlush();	

	for(radiu=0.02; radiu<0.99; radiu += 0.05)
	{
		glColor3f(radiu, 0.5, 1.0);
		for(angle=0.0; angle<2*3.1416; angle+=0.08)
		{	
			ax = radiu*cos(angle);
			ay = radiu*sin(angle);
			
			glBegin(GL_POINTS);
			glVertex3f(ax,  ax*ay/sqrt(ax*ax+ay*ay), ay);			
			glEnd();
			
		}
		glFlush();
		
	}
	glPopMatrix();
	usleep(8);
	}
}

void demo8()
{
	for(aa=0.0; aa<380.0; aa+=1.0)
	{	
	glClear(GL_COLOR_BUFFER_BIT);	
	glPushMatrix();
	glRotatef(aa,0.0,1.0,0.0);
	
	glColor3f(1.0, 0.0, 0.0);
	glBegin(GL_LINES);
	glVertex3f(-1.0,0.0,0.0);
	glVertex3f(1.0,0.0,0.0);   
	glEnd();
	glFlush();


	glColor3f(0.0, 1.0, 0.0);
	glBegin(GL_LINES);
	glVertex3f(0.0,1.0,0.0);
	glVertex3f(0.0,-1.0,0.0);
	glEnd();
	glFlush();
	
	glColor3f(0.0, 0.0, 1.0);
	glBegin(GL_LINES);
	glVertex3f(0.0, 0.0, 1.0);
	glVertex3f(0.0, 0.0, -1.0);
	glEnd();
	glFlush();	

	for(ax=-0.99; ax<0.99; ax+=0.04)
	for(ay=-0.99; ay<0.99; ay += 0.01)
	{
			glColor3f( (2.0-ax-ay)/4, 0.0, 1.0);
			glBegin(GL_POINTS);
			//glVertex3f(ax,  exp(ax*2.0)*log(1.0+ay*2.0)/log(2.718282), ay);			
			glVertex3f(ax,ax*ay/sqrt(ax*ax+ay*ay), ay);			
			glEnd();			
	}	
	glFlush();
	
	for(ay=-0.99; ay<0.99; ay +=0.06)
	for(ax=-0.99; ax<0.99; ax += 0.01)
	{
			glColor3f( (2.0-ax-ay)/4, 0.0, 1.0);
			glBegin(GL_POINTS);
			//glVertex3f(ax,  exp(ax*2.0)*log(1.0+ay*2.0)/log(2.718282), ay);			
			glVertex3f(ax,  ax*ay/sqrt(ax*ax+ay*ay), ay);			
			glEnd();			
}	
		glFlush();
		

	glPopMatrix();
	usleep(4);
	}
}

void demo9()
{
for(aa=0.0; aa<380.0; aa+=1.0)
	{
	glClear(GL_COLOR_BUFFER_BIT);	
	glPushMatrix();
	glRotatef(aa,0.0,0.0, 1.0);
	
	glColor3f(1.0, 0.0, 0.0);
	glBegin(GL_LINES);
	glVertex3f(-1.0,0.0,0.0);
	glVertex3f(1.0,0.0,0.0);   
	glEnd();
	glFlush();


	glColor3f(0.0, 1.0, 0.0);
	glBegin(GL_LINES);
	glVertex3f(0.0,1.0,0.0);
	glVertex3f(0.0,-1.0,0.0);
	glEnd();
	glFlush();
	
	glColor3f(0.0, 0.0, 1.0);
	glBegin(GL_LINES);
	glVertex3f(0.0, 0.0, 1.0);
	glVertex3f(0.0, 0.0, -1.0);
	glEnd();
	glFlush();	

	const double p=0.12;
	const double q=0.15;
	double axx,ayy;
	
	for(radiu=0.01; radiu<0.99; radiu += 0.03)
	{
		glColor3f(radiu, 1.0, 0.1);

		for(angle=thePAI/2.0; angle<2*3.1416; angle+=0.02)
		{	
			ax = radiu*cos(angle);
			ay = radiu*sin(angle);
			axx=10.0*ax;
			ayy=10.0*ay;
			
			
			glBegin(GL_POINTS);

			glVertex3f(ax, ay, func1(ax,ay));
			//glVertex3f(ax, 0.35*sqrt(1-(ax*ax)/0.3-(ay*ay)/0.6),ay);glVertex3f(ax, -0.35*sqrt(1-(ax*ax)/0.3-(ay*ay)/0.6),ay);						
			//glVertex3f(ax, (sin(axx)+cos(ayy))/2.0, ay);			
			//glVertex3f(ax, , ay);			
			//glVertex3f(ax,  exp(sin(axx)) * log(ayy)/10, ay);			
			//glVertex3f(ax,  ax*ay/(ax*ax+ay*ay), ay);			
			//glVertex3f(ax,  (4*(axx-ayy)-axx*axx-ayy*ayy)/150.0, ay);			
			//glVertex3f(ax,  ay*ay/(2*p)-ax*ax/(2*q), ay);			

			glEnd();			
		}
		glFlush();
		
	}
	glPopMatrix();
	usleep(8);
	}
}
void demo10()
{
for(aa=0.0; aa<370.0; aa+=1.0)
	{
	
	
	glClear(GL_COLOR_BUFFER_BIT);	
	glPushMatrix();
	glRotatef(aa,0.0,1.0,0.0);
	
	glColor3f(1.0, 0.0, 0.0);
	glBegin(GL_LINES);
	glVertex3f(-1.0,0.0,0.0);
	glVertex3f(1.0,0.0,0.0);   
	glEnd();
	glFlush();


	glColor3f(0.0, 1.0, 0.0);
	glBegin(GL_LINES);
	glVertex3f(0.0,1.0,0.0);
	glVertex3f(0.0,-1.0,0.0);
	glEnd();
	glFlush();
	
	glColor3f(0.0, 0.0, 1.0);
	glBegin(GL_LINES);
	glVertex3f(0.0, 0.0, 1.0);
	glVertex3f(0.0, 0.0, -1.0);
	glEnd();
	glFlush();	
	

	for(ax=0.01; ax<0.99; ax += 0.035)
	{
		for(ay=0.01; ay<0.99; ay +=0.005)
		{
			//glColor3f( (2.0-ax-ay)/4, 0.0, 1.0);
		    rcolor = ( (1.0-ax)*(1.0-ax) + (1.0-ay)*(1.0-ay) )/2;
			glColor3f(rcolor , rcolor, 1.0);
			glBegin(GL_POINTS);
			//glVertex3f(ax,  exp(ax*2.0)*log(1.0+ay*2.0)/log(2.718282), ay);			
			/*		
			glVertex3f(ax,  ax*ay/(ax*ax+ay*ay), ay);	
			rx=ax;ry=-ay;
			glVertex3f(rx,  rx*ry/(rx*rx+ry*ry), ry);	
			rx=-ax;ry=ay;
			glVertex3f(rx,  rx*ry/(rx*rx+ry*ry), ry);	
			rx=-ax;ry=-ay;
			glVertex3f(rx,  rx*ry/(rx*rx+ry*ry), ry);	
			//*/
			//*
			//glVertex3f(ax, 0.85*sqrt(1-(ax*ax)/0.3-(ay*ay)/0.6),ay);			
			glVertex3f(ax, func1(ax,ay),ay);			

			//glVertex3f(ax, -0.85*sqrt(1-(ax*ax)/0.3-(ay*ay)/0.6),ay);			
			glVertex3f(ax, -func1(ax,ay),ay);			
			//*/
			glEnd();		
		}	
		glFlush();
	}
	for(ay=0.001; ay<0.99; ay +=0.035)
	{
		for(ax=0.001; ax<0.99; ax += 0.005)
		{
		    rcolor = ( (1.0-ax)*(1.0-ax) + (1.0-ay)*(1.0-ay) )/2;
			glColor3f(rcolor , rcolor, 1.0);
			glBegin(GL_POINTS);
			//glVertex3f(ax,  exp(ax*2.0)*log(1.0+ay*2.0)/log(2.718282), ay);			
			/*
			glVertex3f(ax,  ax*ay/(ax*ax+ay*ay), ay);	
			rx=ax;ry=-ay;
			glVertex3f(rx,  rx*ry/(rx*rx+ry*ry), ry);	
			rx=-ax;ry=ay;
			glVertex3f(rx,  rx*ry/(rx*rx+ry*ry), ry);	
			rx=-ax;ry=-ay;
			glVertex3f(rx,  rx*ry/(rx*rx+ry*ry), ry);	
			//*/
			//*
		
			//glVertex3f(ax, 0.85*sqrt(1-(ax*ax)/0.3-(ay*ay)/0.6),ay);			
			//glVertex3f(ax, -0.85*sqrt(1-(ax*ax)/0.3-(ay*ay)/0.6),ay);			
					
			glVertex3f(ax, func1(ax,ay),ay);						
			glVertex3f(ax, -func1(ax,ay),ay);	
			//*/
			glEnd();		
		}	
		glFlush();
	}

	glPopMatrix();
	usleep(5);
	}
}


void demo11()
{
	static GLuint clstnum = 0;
	if(0 == clstnum)
	{
		cout<<"CALL LIST CREATE"<<endl;
		clstnum = glGenLists(1);
		glNewList(clstnum, GL_COMPILE);
		{
			glDisable(GL_TEXTURE_2D);
			glColor3f(1.0, 0.0, 0.0);
			glBegin(GL_LINES);
			glVertex3f(0.0,0.0,0.0);
			glVertex3f(1.0,0.0,0.0);   
			glEnd();

			glColor3f(0.0, 1.0, 0.0);
			glBegin(GL_LINES);
			glVertex3f(0.0,1.0,0.0);
			glVertex3f(0.0,0.0,0.0);
			glEnd();

			glColor3f(0.0, 0.0, 1.0);
			glBegin(GL_LINES);
			glVertex3f(0.0, 0.0, 1.0);
			glVertex3f(0.0, 0.0, 0.0);
			glEnd();

			glColor3f(0.6, 0.0, 0.6);
			//glBegin(GL_POINTS);
			double zt = 0.0;
			double zzt = 0.0;
			double szt = 0.0;
			glEnable(GL_TEXTURE_2D);
			double intv = 0.08;
			for(double xt=-3.14; xt < 3.14; xt += intv)
			{ 	
				zt = cos(xt);
				szt = cos(xt+intv);
				glBegin(GL_TRIANGLE_STRIP);
				for(double yt=-3.14; yt < 3.14; yt += intv)
				{

					zzt = zt + sin(yt);
					zzt /= 2.0;
					glColor3f((4.0-xt)/8.0, 0.0, (2.0-zzt)/4.0);
					glTexCoord2f((4.0-xt)/8.0, (4.0-yt)/8.0);
					glVertex3f(xt/4.0, yt/4.0, zzt);
					
					zzt = szt + sin(yt);
					zzt /= 2.0;
					
					glColor3f((4.0-(xt+intv))/8.0, 0.0, (2.0-zzt)/4.0);
					glTexCoord2f((4.0-(xt+intv))/8.0, (4.0-yt)/8.0);
					glVertex3f((xt+intv)/4.0, yt/4.0, zzt);
					
					//glColor3f(0.6, 0.0, 0.6);
					//glVertex3f(xt/7.0, -xt * xt * yt * (4.0-xt-yt) /20.0, yt/7.0);				
					//glColor3f(0.6, 0.0, 0.0);
					//glVertex3f(yt/7.0, -xt * xt * yt * (4.0-xt-yt) /20.0, xt/7.0);				
				}
				glEnd();
			}
		}
		glEndList();	
	}

	glCallList(clstnum);
}

void aues()
{	
	GLuint the_aues = glGenLists(1);
	glNewList(the_aues, GL_COMPILE);
	{
		glColor3f(1.0, 0.0, 0.0);
		glBegin(GL_LINES);
			glVertex3f(-1.0,0.0,0.0);
			glVertex3f(1.0,0.0,0.0);   
		glEnd();		

		glColor3f(0.0, 1.0, 0.0);
		glBegin(GL_LINES);
			glVertex3f(0.0,1.0,0.0);
			glVertex3f(0.0,-1.0,0.0);
		glEnd();
		
        glColor3f(0.0, 0.0, 1.0);
		glBegin(GL_LINES);
			glVertex3f(0.0, 0.0, 1.0);
			glVertex3f(0.0, 0.0, -1.0);
		glEnd();				
	}	
	glEndList();	
}
 
void demo12()
{

	double xt,yt;
	//glClear(GL_COLOR_BUFFER_BIT);	
	GLuint the_surface = glGenLists(1);
	glNewList(the_surface, GL_COMPILE);
	{
		glColor3f(1.0, 0.0, 0.0);
		glBegin(GL_LINES);
			glVertex3f(-1.0,0.0,0.0);
			glVertex3f(1.0,0.0,0.0);   
		glEnd();		

		glColor3f(0.0, 1.0, 0.0);
		glBegin(GL_LINES);
			glVertex3f(0.0,1.0,0.0);
			glVertex3f(0.0,-1.0,0.0);
		glEnd();
		
        	glColor3f(0.0, 0.0, 1.0);
		glBegin(GL_LINES);
			glVertex3f(0.0, 0.0, 1.0);
			glVertex3f(0.0, 0.0, -1.0);
		glEnd();		

		//glColor3f(1.0, 0.0, 0.0);
		//glutWireSphere(0.8,18,18);
	}
	//*
	{
		glColor3f(1.0, 0.1, 0.6);						
		for(xt=-1.0; xt < 6.2; xt += 0.08)
		{ 	
			//glBegin(GL_POINTS);
			glBegin(GL_LINE_STRIP);
			for(yt=0.0; yt < 6-xt; yt += 0.08)
			{				
				glVertex3f(xt/7.0, yt/7.0, -xt * xt * yt * (4.0-xt-yt) /20.0);					
			}
			glEnd();				
		}
				
	}
	//*/
	glEndList();	
}

void demo13()
{
	double xt,yt;
	glClear(GL_COLOR_BUFFER_BIT);
	
	int thelistnum = glGenLists(1);
	glNewList(thelistnum, GL_COMPILE);
	{
		glColor3f(1.0, 0.0, 0.0);
		glBegin(GL_LINES);
			glVertex3f(-1.0,0.0,0.0);
			glVertex3f(1.0,0.0,0.0);   
		glEnd();		

		glColor3f(0.0, 1.0, 0.0);
		glBegin(GL_LINES);
			glVertex3f(0.0,1.0,0.0);
			glVertex3f(0.0,-1.0,0.0);
		glEnd();
		
        glColor3f(0.0, 0.0, 1.0);
		glBegin(GL_LINES);
			glVertex3f(0.0, 0.0, 1.0);
			glVertex3f(0.0, 0.0, -1.0);
		glEnd();		

		//glColor3f(1.0, 0.0, 0.0);
		//glutWireSphere(0.8,18,18);
	}
	//*
	{
		for(xt=-1.0; xt < 6.2; xt += 0.08)
		{ 	
			glBegin(GL_POINTS);
			
			glColor3f(1.0, 0.2, 0.6);
			for(yt=0.0; yt < 6-xt; yt += 0.08)
			{				
				glVertex3f(xt/7.0, yt/7.0, -xt * xt * yt * (4.0-xt-yt) /20.0);					
			}

			glEnd();
			
			glColor3f(0.5, 1.0, 0.0);
			glBegin(GL_LINES);
				glVertex3f(0.5/7.0, 4.0/7.0, 1.0/7.0 );
				glVertex3f(0.5/7.0, 0.0, 1.0/7.0 );			
			glEnd();	
		}
				
	}
	//*/

	glEndList();	
}

void lunaDraw()
{
	static GLuint clstnum = 0;
	if(0 == clstnum)
	{
		cout<<"CALL LIST CREATE"<<endl;
		clstnum = glGenLists(1);
		glNewList(clstnum, GL_COMPILE);
		{
			glDisable(GL_TEXTURE_2D);
			glColor3f(1.0, 0.0, 0.0);
			glBegin(GL_LINES);
			glVertex3f(0.0,0.0,0.0);
			glVertex3f(100.0,0.0,0.0);   
			glEnd();

			glColor3f(0.0, 1.0, 0.0);
			glBegin(GL_LINES);
			glVertex3f(0.0,0.0,0.0);
			glVertex3f(0.0,100.0,0.0);
			glEnd();

			glColor3f(0.0, 0.0, 1.0);
			glBegin(GL_LINES);
			glVertex3f(0.0, 0.0, 0.0);
			glVertex3f(0.0, 0.0, 100.0);
			glEnd();

			glColor3f(0.6, 0.6, 0.6);
			//glBegin(GL_POINTS);
			double zt = 0.0;
			double zzt = 0.0;
			double szt = 0.0;
			glEnable(GL_TEXTURE_2D);
			double intv = 0.08;
			double lunaRadius = 10.0;
			double highlow, rlow;
			double highhigh, rhigh;
			double nextyt;
			double nextxt;
			for(double xt=0.0; xt < thePAI; xt += intv)
			{ 	
				nextxt = xt + intv;
				if(nextxt >thePAI)
				{
					nextxt = thePAI;
				}
				highlow = lunaRadius*sin(xt-thePAI/2.0);
				rlow = lunaRadius*cos(xt-thePAI/2.0);

				highhigh = lunaRadius*sin(xt+intv-thePAI/2.0);
				rhigh = lunaRadius*cos(xt+intv-thePAI/2.0);

				zt = cos(xt);
				szt = cos(xt+intv);
				glBegin(GL_TRIANGLE_STRIP);
				bool dobreak=false;
				for(double yt=0.0; yt < 3.0*thePAI; yt += intv)
				{
					if(yt>2.0*thePAI)
					{
						yt = 2.0*thePAI;
						dobreak = true;
					}
					glTexCoord2f(yt/(2.0*thePAI), xt/thePAI);
					glVertex3f(rlow*cos(yt), rlow*sin(yt), highlow);

					glTexCoord2f(yt/(2.0*thePAI), nextxt/thePAI);
					glVertex3f(rhigh*cos(yt), rhigh*sin(yt), highhigh);
					if(dobreak)
					{
						break;
					}
				}
				glEnd();
			}
		}
		glEndList();	
	}

	glCallList(clstnum);

}
